﻿Imports System.Data.OleDb

Partial Public Class newArticle
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("mobilestandardsdb").ConnectionString)

        Dim SqlString As String = "Insert into papers(Author,Title,Week_fk_ID,Abstract,Intro,Hyperlink,[User]) Values (@Author,@Title,@Week_fk_ID,@Abstract,@Intro,@Hyperlink,@User)"

        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)

        cmd.CommandType = CommandType.Text

        cmd.Parameters.AddWithValue("@Author", Article_Author.Text)
        cmd.Parameters.AddWithValue("@Title", Article_Title.Text)
        cmd.Parameters.AddWithValue("@Week_fk_ID", DropDownList1.SelectedValue)
        cmd.Parameters.AddWithValue("@Abstract", Article_Abstract.Text)
        cmd.Parameters.AddWithValue("@Intro", Article_Intro.Text)
        cmd.Parameters.AddWithValue("@Hyperlink", Article_Hyperlink.Text)
        cmd.Parameters.AddWithValue("@User", User.Identity.Name)



        oleDbConn.Open()

        cmd.ExecuteNonQuery()

        cmd = New OleDbCommand("SELECT @@IDENTITY", oleDbConn)

        Dim nID = cmd.ExecuteScalar()


        Server.Transfer("newArticleTags.aspx?nID=" & nID)
    End Sub
End Class